package com.sfchen.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication
public class ApiGatewayApplication {
  public static void main(String[] args) throws UnknownHostException {
	SpringApplication app = new SpringApplication(ApiGatewayApplication.class);
	Environment env = app.run(args).getEnvironment();
	String protocol = "http";
	log.info("""
					----------------------------------------------------------
					\tApplication '{}' is running! Access URLs:
					\tLocal: \t\t{}://localhost:{}{}
					\tExternal: \t{}://{}:{}{}
					\tProfile(s): \t{}
					----------------------------------------------------------""",
			 env.getProperty("spring.application.name"),
			 protocol,
			 env.getProperty("server.port"),
			 env.getProperty("server.servlet.context-path"),
			 protocol,
			 InetAddress.getLocalHost().getHostAddress(),
			 env.getProperty("server.port"),
			 env.getProperty("server.servlet.context-path"),
			 env.getActiveProfiles());
  }

}
